#include <string>
#include <fstream>
#include <iostream>
using namespace std;
#include "my_TextQuery.h"
#include "my_StrBlob.h"

void runQueries(ifstream &infile){
    //infile 是一个ifstream 
    TextQuery tq(infile);
    do{
        cout << "enter word to look up or enter q to quit:" << endl;
        string line;
        if(!(cin >> s) || s == "q") break;
        print(cout,tq.query(s)) << endl;
    }while(true);
}

int main(){
    ifstream infile;
    if(argc < 2 || !(infile.open(argv[1]) , infile)){
        cerr << "No input file!" << endl;
        return EXIT_FAILURE;
    }
    runQuerie(infile);
    return 0;
}